package com.shengyuan.manage_os.old.ying.erpm;

import com.shengyuan.manage_os.R;
import com.shengyuan.manage_os.im.common.utils.ToastUtil;
import com.shengyuan.manage_os.old.ying.erpm.controls.PictureButton;
import com.shengyuan.manage_os.old.ying.erpm.controls.SourceSelectMenu;
import com.shengyuan.manage_os.old.ying.erpm.tasks.Submit_System_Setting_Data_Task;
import com.shengyuan.manage_os.old.ying.erpm.util.Utility;
import com.shengyuan.manage_os.utils.ViewTools;

import android.os.Bundle;
import android.view.View;

import org.json.JSONException;

import static com.shengyuan.manage_os.R.id.PictureButton_driver;
import static com.shengyuan.manage_os.R.id.PictureButton_jiayouji;
import static com.shengyuan.manage_os.R.id.PictureButton_jixiebiao;

public class Actual_Form_ZhengCheShouLiao extends BaseActivity {

	@Override
	public void onClick(View view) {
		super.onClick(view);

	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.actual_form_zhengcheshouliao);
		InitControls();
	}

	protected void onCreate(Bundle savedInstanceState,boolean b) {
		super.onCreate(savedInstanceState);
	}
	@Override
	protected void SaveJsonData() {
		try {
			IsJson1 = true; mFinished = 1;
			JsonMyID();
			getCar();
			
			getZhuangdi();
			getTask();
			getCurrentUser();
			getCaiLiao();

			getXiedi();
			getGPS();
			getMemo();
			JsonPicture();
			
			//价格保存
			if (Submit_System_Setting_Data_Task.mID>=0) {
				String YuSuanJiaGe = Submit_System_Setting_Data_Task.J_GONGCHENGMINGCHENG_GC.getJSONObject(Submit_System_Setting_Data_Task.mID).getString("YuSuanJiaGe");
				mJson.put( getString(R.string.title_actual_form_yusuanjiage),  YuSuanJiaGe);
				mJson.put( getString(R.string.title_actual_form_jiage),  YuSuanJiaGe);
			}
		}catch (Exception e) {
		}
	}

	protected void JsonPicture() throws JSONException {
		if (PictureButton_Car!=null) {
			mJson.put( PictureButton_Car.FIELD+getString(R.string.title_actual_form_PictureButton), PictureButton_Car.mFileName);
		}
		if (PictureButton_Chexing!=null) {
			mJson.put( PictureButton_Chexing.FIELD+getString(R.string.title_actual_form_PictureButton), PictureButton_Chexing.mFileName);
		}
		if (PictureButton_CaiLiao!=null) {
			mJson.put( PictureButton_CaiLiao.FIELD+getString(R.string.title_actual_form_PictureButton), PictureButton_CaiLiao.mFileName);
		}
		if (PictureButton_ZhiLiang!=null) {
			mJson.put( PictureButton_ZhiLiang.FIELD+getString(R.string.title_actual_form_PictureButton), PictureButton_ZhiLiang.mFileName);
		}
	}
	@Override
	protected void SaveSelfPic(String sPath) {
		try {
			CopyPicDest(PictureButton_Car, sPath);
			CopyPicDest(PictureButton_Chexing, sPath);
			CopyPicDest(PictureButton_CaiLiao, sPath);
//			CopyPicDest(PictureButton_ZhiLiang, sPath);
		} catch (Exception e) {
			Utility.MessageBox(this,e.getMessage());
		}
	}

	@Override
	public void Back() {
		super.Back();
	}

	@Override
	public void InitControls() {
		super.InitControls();
	}
	
	@Override
	public Boolean IsPassed() {
		if (super.IsPassed()) {
			if (!PictureButton_Car.IsExist()) {
				Utility.MessageBox( this,PictureButton_Car.FIELD );
				return false;
			}
			if (!PictureButton_Chexing.IsExist()) {
				Utility.MessageBox(this, PictureButton_Chexing.FIELD );
				return false;
			}		
			if (!PictureButton_CaiLiao.IsExist()) {
				Utility.MessageBox(this, PictureButton_CaiLiao.FIELD );
				return false;
			}
			if (PictureButton_ZhiLiang!=null && !PictureButton_ZhiLiang.IsExist()) {
				Utility.MessageBox(this, PictureButton_ZhiLiang.FIELD );
				return false;
			}			
			return true;
		}else {
			return false;
		}
	}

}
